package com.hjm.common.utils.yh;

import com.alibaba.fastjson.JSONObject;
import com.hjm.common.utils.request.AutoLoadData;
import com.hjm.common.utils.request.HttpClientUtils;
import com.yxhd.encrypt.EncryptUtils;

import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 进件方法
 * @author maker
 */
public class QbMerUtil
{
    private static String[] folderArray = {"upload", "upload1", "upload2", "upload3", "upload4", "upload5", "upload6",
            "upload7", "upload8", "upload10", "upload12", "upload13", "upload25"};

    private static String ONE = "1";
    private static String ZERO = "0";
    private static String FIVE="5";

    /** 保存日志记录 **/
    private static void saveMerLog(String merno,String content,int type)
    {
        try {
            if (type==0)
            {
                content = EncryptUtils.getEncrypt(content);
            }
        } catch (Exception e) {
        }
        ExceptionLog.merLogInfo(merno,content,type);
    }


    /**上送解绑终端参数到钱宝*/
    public static String sendTerminalUd(Map<String,String> paramMap) throws Exception {
        try{
            Map reqMap = new HashMap(16);
            reqMap.put("termId",paramMap.get("termId"));
            reqMap.put("sn",paramMap.get("machine_num"));
            String s1 = JSONObject.toJSONString(reqMap);
            saveMerLog(paramMap.get("posno") , s1 ,0);
            JSONObject jsonObject = HttpClientUtils.sendHttpPostJson(AutoLoadData.qbtermUdUrl, s1);
            saveMerLog(paramMap.get("posno"),jsonObject.toJSONString(),1);
            System.out.print(jsonObject.toJSONString());
            return jsonObject.toJSONString();
        }catch (Exception e){
            saveMerLog(paramMap.get("posno") , e.getMessage() ,1);
            e.printStackTrace();
        }
        return "";
    }

    public static String toChar(String str){
        String regEx = "[!#$%^&()_+=}\\{\\[\\]?.><,/|`~:;！@#￥%……》《，\\\\（）【】？、；：‘’“”。_——']";
        //这里是将特殊字符换为aa字符串,""代表直接去掉
        String aa = "";
        Pattern p = Pattern.compile(regEx);
        //这里把想要替换的字符串传进来
        Matcher m = p.matcher(str);
        //将替换后的字符串存在变量newString中
        String newString = m.replaceAll(aa).trim();
        return newString;
    }



    public static void main(String[] args) {
        System.out.println(toChar("计算机软硬件开发、咨询服务、广告设计、制作、发布、服务商；家用家电、通讯器材、工艺品"));
    }

}
